/*   1:    */ package org.intellij.plugins.relaxNG;
/*   2:    */ 
/*   3:    */

import com.intellij.javaee.ResourceRegistrar;
import com.intellij.javaee.StandardResourceProvider;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.psi.PsiElement;
import com.intellij.psi.filters.AndFilter;
import com.intellij.psi.filters.ClassFilter;
import com.intellij.psi.filters.ElementFilter;
import com.intellij.psi.filters.position.NamespaceFilter;
import com.intellij.psi.meta.MetaDataRegistrar;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomManager;
import org.intellij.plugins.relaxNG.compact.psi.impl.RncDocument;
import org.intellij.plugins.relaxNG.inspections.RngDomInspection;
import org.intellij.plugins.relaxNG.inspections.UnusedDefineInspection;
import org.intellij.plugins.relaxNG.model.descriptors.RngNsDescriptor;
import org.intellij.plugins.relaxNG.validation.ValidateAction;
import org.intellij.plugins.relaxNG.xml.dom.RngDefine;
import org.intellij.plugins.relaxNG.xml.dom.impl.RngDefineMetaData;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */
/*  25:    */
/*  26:    */
/*  27:    */ 
/*  28:    */ public class ApplicationLoader
/*  29:    */   implements ApplicationComponent
/*  30:    */ {
/*  31:    */   private static final String a = "rng";
/*  32:    */   private static final String b = "ValidateXml";
/*  33:    */   public static final String RNG_NAMESPACE = "http://relaxng.org/ns/structure/1.0";
/*  34:    */   
/*  35:    */   @NonNls
/*  36:    */   @NotNull
/*  37:    */   public String getComponentName()
/*  38:    */   {
/*  39: 57 */     String tmp2_0 = "Relax-NG";
/*  40: 57 */     if (tmp2_0 == null) {
/*  41: 57 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/ApplicationLoader", "getComponentName" }));
/*  42:    */     }
/*  43: 57 */     return tmp2_0;
/*  44:    */   }
/*  45:    */   
/*  46:    */   public void initComponent()
/*  47:    */   {
/*  48: 61 */     b();
/*  49:    */     
/*  50: 63 */     a();
/*  51:    */   }
/*  52:    */   
/*  53:    */   private static void a()
/*  54:    */   {
/*  55: 67 */     ActionManager localActionManager = ActionManager.getInstance();
/*  56: 68 */     AnAction localAnAction = localActionManager.getAction("ValidateXml");
/*  57: 69 */     localActionManager.unregisterAction("ValidateXml");
/*  58: 70 */     localActionManager.registerAction("ValidateXml", new ValidateAction(localAnAction));
/*  59:    */   }
/*  60:    */   
/*  61:    */   private static void b()
/*  62:    */   {
/*  63: 74 */     MetaDataRegistrar localMetaDataRegistrar = MetaDataRegistrar.getInstance();
/*  64: 75 */     localMetaDataRegistrar.registerMetaData(new AndFilter(new NamespaceFilter(new String[] { "http://relaxng.org/ns/structure/1.0" }), new ClassFilter(XmlDocument.class)), RngNsDescriptor.class);
/*  65:    */     
/*  66:    */ 
/*  67:    */ 
/*  68:    */ 
/*  69:    */ 
/*  70:    */ 
/*  71: 82 */     localMetaDataRegistrar.registerMetaData(new ClassFilter(RncDocument.class), RngNsDescriptor.class);
/*  72:    */     
/*  73:    */ 
/*  74:    */ 
/*  75: 86 */     localMetaDataRegistrar.registerMetaData(new ElementFilter()
/*  76:    */     {
/*  77:    */       public boolean isAcceptable(Object paramAnonymousObject, PsiElement paramAnonymousPsiElement)
/*  78:    */       {
/*  79: 88 */         if ((paramAnonymousObject instanceof XmlTag))
/*  80:    */         {
/*  81: 89 */           XmlTag localXmlTag = (XmlTag)paramAnonymousObject;
/*  82: 90 */           DomElement localDomElement = DomManager.getDomManager(localXmlTag.getProject()).getDomElement(localXmlTag);
/*  83: 91 */           return localDomElement instanceof RngDefine;
/*  84:    */         }
/*  85: 93 */         return false;
/*  86:    */       }
/*  87:    */       
/*  88:    */       public boolean isClassAcceptable(Class paramAnonymousClass)
/*  89:    */       {
/*  90: 97 */         return XmlTag.class.isAssignableFrom(paramAnonymousClass);
/*  91:    */       }
/*  92: 97 */     }, RngDefineMetaData.class);
/*  93:    */   }
/*  94:    */   
/*  95:    */   public void disposeComponent() {}
/*  96:    */   
/*  97:    */   public static Class[] getInspectionClasses()
/*  98:    */   {
/*  99:106 */     return new Class[] { RngDomInspection.class, UnusedDefineInspection.class };
/* 100:    */   }
/* 101:    */   
/* 102:    */   public static class ResourceProvider
/* 103:    */     implements StandardResourceProvider
/* 104:    */   {
/* 105:    */     public void registerResources(ResourceRegistrar paramResourceRegistrar)
/* 106:    */     {
/* 107:114 */       paramResourceRegistrar.addStdResource("http://relaxng.org/ns/structure/1.0", "/resources/relaxng.rng", getClass());
/* 108:115 */       paramResourceRegistrar.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0");
/* 109:    */     }
/* 110:    */   }
/* 111:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.ApplicationLoader

 * JD-Core Version:    0.7.0.1

 */